<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>

	  function demo (count) {
	    const data = []
	    let current = 0;
	    (async () => {
	      const hanldeAsync = () => new Promise((resolve) => {
	        const rec = () => {
	          setTimeout(function () {
	            const value = current
	            data.push({
	              value: value,
	              preData: current === 0 ? null : data[current - 1].value
	            })
	            current++
	            if (current === count) {
	              return resolve(data)
	            }
	            rec()
	          }, 1000)
	        }
	        rec()
	      })
	      data = await hanldeAsync()
	    })()
	    return data
	  }

	  // demo(5).then(res => {
	  //   console.log(demo(res))
	  // })
	  console.log(demo(5))
  </script>
</body>
</html>